const insertSort = (list) => {
  if (list.length <= 1) return list
  for (let i = 1; i < list.length; i++) {
    const pivot = list[i]
    let j = i - 1
    while (j >= 0 && (list[j] > pivot)) {
      list[j + 1] = list[j]
      j--
    }
    list[j + 1] = pivot
  }
  return list
}
const arr = [1,4,3,6,5,8,7,2,9,0]
console.log(insertSort(arr));